<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Setup extends CI_Controller {

    private $limit = 10;

    function __construct() {
        parent::__construct();
		if((!check_auth()) ? redirect("/login/auth") : site_url("/home"));
        $this->load->library('Mypaging');
        $this->load->model('setup_model');
		$this->load->helper('date');
    }
	
	//===============================================================================================================
    // WAREHOUSE CONTROLLER ~ SURYA ALAM GULTOM 
    //===============================================================================================================
	
	function ga_warehouse() {
		$arr['search_by_name'] = trim($this->input->post('search_by_name'));
        $arr['search_by_status'] = trim($this->input->post('search_by_status'));

        $this->mypaging->items_total = $this->setup_model->count_warehouse_item($arr);
        $this->mypaging->function_load = "load_page_warehouse";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 9;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
		
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();
		
		$data['list_data'] = $this->setup_model->list_warehouse_item($arr, $limit);
        $this->load->view('setup_warehouse/warehouse_list_view', $data);
	}
	
	function load_page_warehouse() {
        $cek1 = $this->session->flashdata('search_by_name');
        $cek2 = $this->session->flashdata('search_by_status');
        
        if ($cek1 != '' || $cek2 != '') {
            $arr['search_by_name'] = trim($this->session->flashdata('search_by_name'));
            $arr['search_by_status'] = trim($this->session->flashdata('search_by_status'));
        } else {
            $arr['search_by_name'] = trim($this->input->post('search_by_name'));
            $arr['search_by_status'] = trim($this->input->post('search_by_status'));
        }

        $this->mypaging->items_total = $this->setup_model->count_warehouse_item($arr);
        $this->mypaging->function_load = "load_page_warehouse";
        $this->mypaging->post_page = trim($this->input->post("page"));
        $this->mypaging->post_ipp = trim($this->input->post("ipp"));
        $this->mypaging->mid_range = 9;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
		
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->search_warehouse_item($arr, $limit);
        $this->load->view('setup_warehouse/warehouse_search_view', $data);		
    }
	
	function search_warehouse() {
        $arr['search_by_name'] = trim($this->input->post('search_by_name'));
        $arr['search_by_status'] = trim($this->input->post('search_by_status'));      

        $this->mypaging->items_total = $this->setup_model->count_warehouse_item($arr);
        $this->mypaging->function_load = "load_page_warehouse";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 9;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
		
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->search_warehouse_item($arr, $limit);
        $this->load->view('setup_warehouse/warehouse_search_view', $data);
    }
	
	function activation_item() {
        $arr['warehouse_id'] = trim($this->input->post('warehouse_id'));
        $arr['cond'] = ($this->input->post('cond')=='Y') ? 'N' : 'Y';        
        $this->setup_model->update_status_item($arr);
    }
	
	function add_item_view() {
		$this->load->view('setup_warehouse/item_add_view');
    }
	
	function edit_item_view() {
		$arr['warehouse_id'] = trim($this->input->post('warehouse_id'));
        $data['detail_item'] = $this->setup_model->item_list($arr);
		
		$data['warehouse_id'] = trim($this->input->post('warehouse_id'));
        $this->load->view('setup_warehouse/item_edit_view', $data);
    }
	
	function delete_item() {	
		$arr['warehouse_id'] = trim($this->input->post('warehouse_id'));		
		$this->setup_model->delete_item($arr);
		
		$arr['search_by_name'] = trim($this->input->post('search_by_name'));
        $arr['search_by_status'] = trim($this->input->post('search_by_status'));

        $this->mypaging->items_total = $this->setup_model->count_warehouse_item($arr);
        $this->mypaging->function_load = "load_page_warehouse";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 9;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
		
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();
		
		$data['list_data'] = $this->setup_model->list_warehouse_item($arr, $limit);
        $this->load->view('setup_warehouse/warehouse_list_view', $data);
	}
	
	function insert_item() {
		$arr['item'] = trim($this->input->post('item'));
		$arr['qty'] = trim($this->input->post('qty'));
		$arr['qty_active'] = trim($this->input->post('qty_active'));
		$arr['qty_not_active'] = trim($this->input->post('qty_not_active'));
		$arr['status'] = trim($this->input->post('status'));		        
        $this->setup_model->insert_item($arr);
	}

	function update_item() {
		$arr['warehouse_id'] = trim($this->input->post('warehouse_id'));
		$arr['item'] = trim($this->input->post('item'));
		$arr['qty'] = trim($this->input->post('qty'));
		$arr['qty_active'] = trim($this->input->post('qty_active'));
		$arr['qty_not_active'] = trim($this->input->post('qty_not_active'));
		$arr['status'] = trim($this->input->post('status'));		
		$this->setup_model->update_item($arr);
	}
	
	//===============================================================================================================
	// BORROW CONTROLLER ~ SURYA ALAM GULTOM 
	//===============================================================================================================
	
	function item_borrow() {
		$arr['search_by_name'] = trim($this->input->post('search_by_name'));
		$arr['search_by_status'] = trim($this->input->post('search_by_status'));        

        $this->mypaging->items_total = $this->setup_model->count_borrow($arr);
        $this->mypaging->function_load = "load_page_borrow";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 9;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
		
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();
		
		$data['dt1'] = date("d/m/Y",now());	
		$data['dt2'] = date("d/m/Y",now());
		
		$data['list_data'] = $this->setup_model->list_borrow($arr, $limit);
        $this->load->view('setup_warehouse/borrow_list_view', $data);
	}
	
	function load_page_borrow() {
        $cek1 = $this->session->flashdata('search_by_name');
		$cek2 = $this->session->flashdata('search_by_status');		
        
        if ($cek1 != '' || $cek2 != '') {
            $arr['search_by_name'] = trim($this->session->flashdata('search_by_name'));
			$arr['search_by_status'] = trim($this->session->flashdata('search_by_status'));            
        } else {
            $arr['search_by_name'] = trim($this->input->post('search_by_name'));
			$arr['search_by_status'] = trim($this->input->post('search_by_status'));            
        }

        $this->mypaging->items_total = $this->setup_model->count_borrow($arr);
        $this->mypaging->function_load = "load_page_borrow";
        $this->mypaging->post_page = trim($this->input->post("page"));
        $this->mypaging->post_ipp = trim($this->input->post("ipp"));
        $this->mypaging->mid_range = 9;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
		
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->search_borrow($arr, $limit);
        $this->load->view('setup_warehouse/borrow_search_view', $data);		
    }
	
	function search_borrow() {
        $arr['search_by_name'] = trim($this->input->post('search_by_name'));
		$arr['search_by_status'] = trim($this->input->post('search_by_status'));        

        $this->mypaging->items_total = $this->setup_model->count_borrow($arr);
        $this->mypaging->function_load = "load_page_borrow";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 9;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
		
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->search_borrow($arr, $limit);
        $this->load->view('setup_warehouse/borrow_search_view', $data);
    }
	
	function activation_order() {
        $arr['roomd_id'] = trim($this->input->post('roomd_id'));
        $arr['cond'] = ($this->input->post('cond')=='Y') ? 'N' : 'Y';        
        $this->setup_model->update_status_order($arr);
    }
	
	//===============================================================================================================
    // WORK FACILITY CONTROLLER ~ SURYA ALAM GULTOM 
    //===============================================================================================================
	
	function work_facility() {
		$data['list_fasilitas_kerja'] 		= $this->setup_model->list_work_facility();
		$data['list_fasilitas_ruang_kerja'] = $this->setup_model->list_room_facility();
		$this->load->view('setup_facility/work_facility_view', $data);
	}		
	
	function add_facility() {
		$arr['name'] = trim($this->input->post('name'));		
		$arr['type'] = trim($this->input->post('type'));
		$arr['desc'] = trim($this->input->post('desc'));
        $this->setup_model->add_facility($arr);		
		// $this->session->set_flashdata('Success', 'Facility successfully inserted!');
	}
	
	function edit_facility() {
		$arr['name_old'] = trim($this->input->post('name_old'));		
		$arr['name'] = trim($this->input->post('name'));
		$arr['type'] = trim($this->input->post('type'));
		$arr['desc'] = trim($this->input->post('desc'));
        $this->setup_model->edit_facility($arr);	
		// $this->session->set_flashdata('Success', 'Facility successfully edited!');
	}
	
	function delete_facility() {
		$arr['name'] = trim($this->input->post('name'));		
		$arr['type'] = trim($this->input->post('type'));
        $this->setup_model->delete_facility($arr);
		
		$data['list_fasilitas_kerja'] 		= $this->setup_model->list_work_facility();
		$data['list_fasilitas_ruang_kerja'] = $this->setup_model->list_room_facility();
		$this->load->view('setup_facility/work_facility_view', $data);
	}
	
	function add_facility_view() {
		$data['type'] = trim($this->input->post('type'));
		$this->load->view('setup_facility/add_facility_view', $data);
	}
	
	function edit_facility_view() {
		$data['name'] = trim($this->input->post('name'));
		$data['type'] = trim($this->input->post('type'));
		$data['desc'] = trim($this->input->post('desc'));
		$this->load->view('setup_facility/edit_facility_view', $data);
	}
	
	//===============================================================================================================
    // JOB POSITION CONTROLLER ~ SURYA ALAM GULTOM 
    //===============================================================================================================
	
	function job_position() {
		$data['nama_jabatan'] = trim($this->input->post('nama_jabatan'));
		$data['status_name'] = trim($this->input->post('status_name'));
		
		$data['floor_name'] = trim($this->input->post('floor_name'));
		$data['nama_jabatan2'] = trim($this->input->post('nama_jabatan2'));
				
		$data['ruang_name'] = trim($this->input->post('ruang_name'));
		$data['new_room'] = trim($this->input->post('new_room'));				
		
		$data['job_select'] = $this->setup_model->getJobList();
		$data['job_select2'] = $this->setup_model->getJobList();
		$data['floor_select'] = $this->setup_model->getFloorList();
		
		$data['list_fasilitas_kerja'] 		= $this->setup_model->list_work_facility();
		$data['list_fasilitas_ruang_kerja'] = $this->setup_model->list_room_facility();
		$data['list_fasilitas_ruang_kerja2'] = $this->setup_model->list_room_facility();
		$this->load->view('setup_facility/job_position_view', $data);
	}
	
	function ShowRoomRequest() {
		$floor_name = $_POST['floor_name'];
		$data['get_Room'] = $this->setup_model->getRoom($floor_name);		
		$this->load->view('setup_facility/ShowRoomRequest', $data);
	}
	
	function search_data1() {
		$arr['nama_jabatan'] = trim($this->input->post('nama_jabatan'));
		$arr['status_name'] = trim($this->input->post('status_name'));		
		
		$data['list_data1'] = $this->setup_model->list_data1($arr);				
		$data['list_data2'] = $this->setup_model->list_data2($arr);
		
		$data['nama_jabatan'] = trim($this->input->post('nama_jabatan'));
		$data['status_name'] = trim($this->input->post('status_name'));
		
		$data['job_select'] = $this->setup_model->getJobList();	
		
		$data['list_fasilitas_kerja'] = $this->setup_model->list_work_facility();
		$data['list_fasilitas_kerja_new'] = $this->setup_model->list_work_facility_new($arr);		
		$data['list_fasilitas_ruang_kerja'] = $this->setup_model->list_room_facility();
		$data['list_fasilitas_ruang_kerja_new'] = $this->setup_model->list_room_facility_new($arr);				
		$this->load->view('setup_facility/job_search_view', $data);
	}
	
	function search_data2() {
		$arr['floor_name'] = trim($this->input->post('floor_name'));
		$arr['nama_jabatan2'] = trim($this->input->post('nama_jabatan2'));
		$arr['ruang_name'] = trim($this->input->post('ruang_name'));		
		$arr['new_room'] = trim($this->input->post('new_room'));
		
		$data['list_data3'] = $this->setup_model->list_data3($arr);	
		$data['list_data4'] = $this->setup_model->list_data4($arr);	
		
		$data['floor_name'] = trim($this->input->post('floor_name'));
		$data['nama_jabatan2'] = trim($this->input->post('nama_jabatan2'));
		$data['ruang_name'] = trim($this->input->post('ruang_name'));				
		$data['new_room'] = trim($this->input->post('new_room'));
		
		$data['floor_select'] = $this->setup_model->getFloorList();
		$data['job_select2'] = $this->setup_model->getJobList();
		
		$data['list_fasilitas_request'] = $this->setup_model->list_fasilitas_request($arr);
		
		$this->load->view('setup_facility/job_search2_view', $data);
	}
	
	function add_data1() {
		$arr7['nama_jabatan'] = trim($this->input->post('nama_jabatan'));
		$arr7['status_name'] = trim($this->input->post('status_name'));
		$arr7['work_awal'] = trim($this->input->post('work_awal'));
		$arr7['status_awal'] = trim($this->input->post('status_awal'));				
		$data['save_data'] = $this->setup_model->add_data1($arr7);		
		
		$arr['nama_jabatan'] = trim($this->input->post('nama_jabatan'));
		$arr['status_name'] = trim($this->input->post('status_name'));		
		
		$data['list_data1'] = $this->setup_model->list_data1($arr);				
		$data['list_data2'] = $this->setup_model->list_data2($arr);
		
		$data['nama_jabatan'] = trim($this->input->post('nama_jabatan'));
		$data['status_name'] = trim($this->input->post('status_name'));
		
		$data['job_select'] = $this->setup_model->getJobList();		
		
		$data['list_fasilitas_kerja'] = $this->setup_model->list_work_facility();
		$data['list_fasilitas_kerja_new'] = $this->setup_model->list_work_facility_new($arr);		
		$data['list_fasilitas_ruang_kerja'] = $this->setup_model->list_room_facility();
		$data['list_fasilitas_ruang_kerja_new'] = $this->setup_model->list_room_facility_new($arr);				
		$this->load->view('setup_facility/job_search_view', $data);
	}
	
	function add_data2() {
		$arr8['nama_jabatan'] = trim($this->input->post('nama_jabatan'));
		$arr8['status_name'] = trim($this->input->post('status_name'));
		$arr8['work2_awal'] = trim($this->input->post('work2_awal'));
		$arr8['status2_awal'] = trim($this->input->post('status2_awal'));				
		$data['save2_data'] = $this->setup_model->add_data2($arr8);		
		
		$arr['nama_jabatan'] = trim($this->input->post('nama_jabatan'));
		$arr['status_name'] = trim($this->input->post('status_name'));		
		
		$data['list_data1'] = $this->setup_model->list_data1($arr);				
		$data['list_data2'] = $this->setup_model->list_data2($arr);
		
		$data['nama_jabatan'] = trim($this->input->post('nama_jabatan'));
		$data['status_name'] = trim($this->input->post('status_name'));
		
		$data['job_select'] = $this->setup_model->getJobList();		
		
		$data['list_fasilitas_kerja'] = $this->setup_model->list_work_facility();
		$data['list_fasilitas_kerja_new'] = $this->setup_model->list_work_facility_new($arr);		
		$data['list_fasilitas_ruang_kerja'] = $this->setup_model->list_room_facility();
		$data['list_fasilitas_ruang_kerja_new'] = $this->setup_model->list_room_facility_new($arr);				
		$this->load->view('setup_facility/job_search_view', $data);
	}
	
	function add_data3() {
		$arr5['floor_name'] = trim($this->input->post('floor_name'));
		$arr5['nama_jabatan2'] = trim($this->input->post('nama_jabatan2'));
		$arr5['new_room'] = trim($this->input->post('new_room'));
		$arr5['work_awal3'] = trim($this->input->post('work_awal3'));		
		$arr5['type_save'] = trim($this->input->post('type_save'));
		$arr5['status_awal3'] = trim($this->input->post('status_awal3'));				
		
		$data['save3_data'] = $this->setup_model->add_data3($arr5);		
		
		$arr['floor_name'] = trim($this->input->post('floor_name'));
		$arr['nama_jabatan2'] = trim($this->input->post('nama_jabatan2'));
		$arr['ruang_name'] = trim($this->input->post('new_room'));		
		$arr['new_room'] = trim($this->input->post('new_room'));
		
		$data['list_data3'] = $this->setup_model->list_data3($arr);	
		$data['list_data4'] = $this->setup_model->list_data4($arr);	
		
		$data['floor_name'] = trim($this->input->post('floor_name'));
		$data['nama_jabatan2'] = trim($this->input->post('nama_jabatan2'));
		$data['ruang_name'] = trim($this->input->post('new_room'));				
		
		$data['floor_select'] = $this->setup_model->getFloorList();
		$data['job_select2'] = $this->setup_model->getJobList();
		
		$data['list_fasilitas_request'] = $this->setup_model->list_fasilitas_request($arr);
		
		$this->load->view('setup_facility/job_search2_view', $data);
	}
	
	function edit_data1() {
		$arr3['ri_name'] = trim($this->input->post('ri_name'));
		$arr3['ri_jabatan_name'] = trim($this->input->post('ri_jabatan_name'));
		$arr3['ri_jabatan_status'] = trim($this->input->post('ri_jabatan_status'));
		$arr3['ri_status'] = trim($this->input->post('ri_status'));
		$data['edit_data'] = $this->setup_model->edit_data1($arr3);
		
		$arr['nama_jabatan'] = trim($this->input->post('ri_jabatan_name'));
		$arr['status_name'] = trim($this->input->post('ri_jabatan_status'));		
		
		$data['list_data1'] = $this->setup_model->list_data1($arr);				
		$data['list_data2'] = $this->setup_model->list_data2($arr);
		
		$data['nama_jabatan'] = trim($this->input->post('ri_jabatan_name'));
		$data['status_name'] = trim($this->input->post('ri_jabatan_status'));
		
		$data['job_select'] = $this->setup_model->getJobList();		
		
		$data['list_fasilitas_kerja'] = $this->setup_model->list_work_facility();
		$data['list_fasilitas_kerja_new'] = $this->setup_model->list_work_facility_new($arr);		
		$data['list_fasilitas_ruang_kerja'] = $this->setup_model->list_room_facility();
		$data['list_fasilitas_ruang_kerja_new'] = $this->setup_model->list_room_facility_new($arr);				
		$this->load->view('setup_facility/job_search_view', $data);
	}
	
	function edit_data2() {
		$arr3['rui_name'] = trim($this->input->post('rui_name'));
		$arr3['rui_jabatan_name'] = trim($this->input->post('rui_jabatan_name'));
		$arr3['rui_jabatan_status'] = trim($this->input->post('rui_jabatan_status'));
		$arr3['rui_status'] = trim($this->input->post('rui_status'));
		$data['edit2_data'] = $this->setup_model->edit_data2($arr3);
		
		$arr['nama_jabatan'] = trim($this->input->post('rui_jabatan_name'));
		$arr['status_name'] = trim($this->input->post('rui_jabatan_status'));		
		
		$data['list_data1'] = $this->setup_model->list_data1($arr);				
		$data['list_data2'] = $this->setup_model->list_data2($arr);
		
		$data['nama_jabatan'] = trim($this->input->post('rui_jabatan_name'));
		$data['status_name'] = trim($this->input->post('rui_jabatan_status'));
		
		$data['job_select'] = $this->setup_model->getJobList();		
		
		$data['list_fasilitas_kerja'] = $this->setup_model->list_work_facility();
		$data['list_fasilitas_kerja_new'] = $this->setup_model->list_work_facility_new($arr);		
		$data['list_fasilitas_ruang_kerja'] = $this->setup_model->list_room_facility();
		$data['list_fasilitas_ruang_kerja_new'] = $this->setup_model->list_room_facility_new($arr);				
		$this->load->view('setup_facility/job_search_view', $data);
	}
	
	function edit_data3() {
		$arr5['rbl_job'] 		= trim($this->input->post('rbl_job'));
		$arr5['rbl_item_id'] 	= trim($this->input->post('rbl_item_id'));
		$arr5['rbl_item_tipe'] 	= trim($this->input->post('rbl_item_tipe'));
		$arr5['rbl_item_flag'] 	= trim($this->input->post('rbl_item_flag'));
		$data['edit3_data'] 	= $this->setup_model->edit_data3($arr5);
		
		$arr['floor_name'] = trim($this->input->post('floor_name'));
		$arr['nama_jabatan2'] = trim($this->input->post('rbl_job'));
		$arr['ruang_name'] = trim($this->input->post('ruang_name'));		
		$arr['new_room'] = trim($this->input->post('new_room'));
		
		$data['list_data3'] = $this->setup_model->list_data3($arr);	
		$data['list_data4'] = $this->setup_model->list_data4($arr);	
		
		$data['floor_name'] = trim($this->input->post('floor_name'));
		$data['nama_jabatan2'] = trim($this->input->post('rbl_job'));
		$data['ruang_name'] = trim($this->input->post('ruang_name'));				
		$data['new_room'] = trim($this->input->post('new_room'));
		
		$data['floor_select'] = $this->setup_model->getFloorList();
		$data['job_select2'] = $this->setup_model->getJobList();
		
		$data['list_fasilitas_request'] = $this->setup_model->list_fasilitas_request($arr);
		
		$this->load->view('setup_facility/job_search2_view', $data);
	}
	
	function delete_data1() {
		$arr9['ri_name'] = trim($this->input->post('ri_name'));
		$arr9['ri_jabatan_name'] = trim($this->input->post('ri_jabatan_name'));
		$arr9['ri_jabatan_status'] = trim($this->input->post('ri_jabatan_status'));
		$data['delete_data'] = $this->setup_model->delete_data1($arr9);
		
		$arr['nama_jabatan'] = trim($this->input->post('ri_jabatan_name'));
		$arr['status_name'] = trim($this->input->post('ri_jabatan_status'));		
		
		$data['list_data1'] = $this->setup_model->list_data1($arr);				
		$data['list_data2'] = $this->setup_model->list_data2($arr);
		
		$data['nama_jabatan'] = trim($this->input->post('ri_jabatan_name'));
		$data['status_name'] = trim($this->input->post('ri_jabatan_status'));
		
		$data['job_select'] = $this->setup_model->getJobList();		
		
		$data['list_fasilitas_kerja'] = $this->setup_model->list_work_facility();
		$data['list_fasilitas_kerja_new'] = $this->setup_model->list_work_facility_new($arr);		
		$data['list_fasilitas_ruang_kerja'] = $this->setup_model->list_room_facility();
		$data['list_fasilitas_ruang_kerja_new'] = $this->setup_model->list_room_facility_new($arr);				
		$this->load->view('setup_facility/job_search_view', $data);
	}
	
	function delete_data2() {
		$arr9['rui_name'] = trim($this->input->post('rui_name'));
		$arr9['rui_jabatan_name'] = trim($this->input->post('rui_jabatan_name'));
		$arr9['rui_jabatan_status'] = trim($this->input->post('rui_jabatan_status'));
		$data['delete2_data'] = $this->setup_model->delete_data2($arr9);
		
		$arr['nama_jabatan'] = trim($this->input->post('rui_jabatan_name'));
		$arr['status_name'] = trim($this->input->post('rui_jabatan_status'));		
		
		$data['list_data1'] = $this->setup_model->list_data1($arr);				
		$data['list_data2'] = $this->setup_model->list_data2($arr);
		
		$data['nama_jabatan'] = trim($this->input->post('rui_jabatan_name'));
		$data['status_name'] = trim($this->input->post('rui_jabatan_status'));
		
		$data['job_select'] = $this->setup_model->getJobList();		
		
		$data['list_fasilitas_kerja'] = $this->setup_model->list_work_facility();
		$data['list_fasilitas_kerja_new'] = $this->setup_model->list_work_facility_new($arr);		
		$data['list_fasilitas_ruang_kerja'] = $this->setup_model->list_room_facility();
		$data['list_fasilitas_ruang_kerja_new'] = $this->setup_model->list_room_facility_new($arr);				
		$this->load->view('setup_facility/job_search_view', $data);
	}
	
	function delete_data3() {
		$arr9['rbl_id'] = trim($this->input->post('rbl_id'));
		$data['delete3_data'] = $this->setup_model->delete_data3($arr9);
		
		$arr['floor_name'] = trim($this->input->post('floor_name'));
		$arr['nama_jabatan2'] = trim($this->input->post('nama_jabatan2'));
		$arr['ruang_name'] = trim($this->input->post('ruang_name'));		
		$arr['new_room'] = trim($this->input->post('new_room'));
		
		$data['list_data3'] = $this->setup_model->list_data3($arr);	
		$data['list_data4'] = $this->setup_model->list_data4($arr);	
		
		$data['floor_name'] = trim($this->input->post('floor_name'));
		$data['nama_jabatan2'] = trim($this->input->post('nama_jabatan2'));
		$data['ruang_name'] = trim($this->input->post('ruang_name'));				
		$data['new_room'] = trim($this->input->post('new_room'));
		
		$data['floor_select'] = $this->setup_model->getFloorList();
		$data['job_select2'] = $this->setup_model->getJobList();
		
		$data['list_fasilitas_request'] = $this->setup_model->list_fasilitas_request($arr);
		
		$this->load->view('setup_facility/job_search2_view', $data);
	}
	
	//===============================================================================================================
    // CONTRACT CONTROLLER ~ SURYA ALAM GULTOM 
    //===============================================================================================================
	
	function contract() {
        $arr['search_by_id'] = trim($this->input->post('search_by_id'));
        $arr['search_by_no'] = trim($this->input->post('search_by_no'));
		$arr['search_by_title'] = trim($this->input->post('search_by_title'));
		$arr['search_by_vendor'] = trim($this->input->post('search_by_vendor'));
		
		$this->mypaging->items_total = $this->setup_model->count_contract($arr);
        $this->mypaging->function_load = "load_page_contract";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 9;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
		
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();
		
		$data['list_data'] = $this->setup_model->list_contract($arr, $limit);
        $this->load->view('setup_contract/contract_list_view', $data);
    }
	
	function search_contract() {
        $arr['search_by_id'] = trim($this->input->post('search_by_id'));
        $arr['search_by_no'] = trim($this->input->post('search_by_no'));
		$arr['search_by_title'] = trim($this->input->post('search_by_title'));
		$arr['search_by_vendor'] = trim($this->input->post('search_by_vendor'));

        $this->mypaging->items_total = $this->setup_model->count_contract($arr);
        $this->mypaging->function_load = "load_page_contract";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 9;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
		
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->search_contract($arr, $limit);
        $this->load->view('setup_contract/contract_search_view', $data);
    }
	
	function load_page_contract() {
        $cek1 = $this->session->flashdata('search_by_id');
        $cek2 = $this->session->flashdata('search_by_no');
        $cek3 = $this->session->flashdata('search_by_title');
		$cek4 = $this->session->flashdata('search_by_vendor');
        
        if ($cek1 != '' || $cek2 != ''|| $cek3 != ''|| $cek4 != '') {
            $arr['search_by_id'] = trim($this->session->flashdata('search_by_id'));
            $arr['search_by_no'] = trim($this->session->flashdata('search_by_no'));
            $arr['search_by_title'] = trim($this->session->flashdata('search_by_title'));
			$arr['search_by_vendor'] = trim($this->session->flashdata('search_by_vendor'));
        } else {
            $arr['search_by_id'] = trim($this->input->post('search_by_id'));
            $arr['search_by_no'] = trim($this->input->post('search_by_no'));
            $arr['search_by_title'] = trim($this->input->post('search_by_title'));
			$arr['search_by_vendor'] = trim($this->input->post('search_by_vendor'));
        }

        $this->mypaging->items_total = $this->setup_model->count_contract($arr);
        $this->mypaging->function_load = "load_page_contract";
        $this->mypaging->post_page = trim($this->input->post("page"));
        $this->mypaging->post_ipp = trim($this->input->post("ipp"));
        $this->mypaging->mid_range = 9;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
		
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->search_contract($arr, $limit);
        $this->load->view('setup_contract/contract_search_view', $data);
    }
	
	function add_contract() {
		$data['dt1'] = date("d/m/Y",now());	
		$data['dt2'] = date("d/m/Y",now());
		
		$data['type_select'] = $this->setup_model->getTypePriceList();
		$data['vendor_select'] = $this->setup_model->getVendorList();
		$data['satuan_select'] = $this->setup_model->getTypeSatuanList();		
        $this->load->view('setup_contract/contract_add_view', $data);
    }
	
	function edit_contract() {
		$data['dt1'] = date("d/m/Y",now());	
		$data['dt2'] = date("d/m/Y",now());
		
		$data['type_select'] = $this->setup_model->getTypePriceList();
		$data['vendor_select'] = $this->setup_model->getVendorList();
		$data['satuan_select'] = $this->setup_model->getTypeSatuanList();
		
        $arr['doc_id'] = trim($this->input->post('doc_id'));
		$arr['doc_induk'] = trim($this->input->post('doc_induk'));
		
        $data['detail_data'] = $this->setup_model->contract_list_updated($arr);
		$data['table_data'] = $this->setup_model->contract_table_updated($arr);
        
		$data['status_id'] = trim($this->input->post('status_id'));
		$this->load->view('setup_contract/contract_edit_view', $data);
    }
	
	function insert_data_contract() {
		$arr['vendor_id'] = trim($this->input->post('vendor_id'));
		$arr['doc_no'] = trim($this->input->post('doc_no'));
		$arr['doc_title'] = trim($this->input->post('doc_title'));
		$arr['date1'] = trim($this->input->post('date1'));
		$arr['date2'] = trim($this->input->post('date2'));
		$arr['description'] = trim($this->input->post('description'));
		$arr['reminder'] = trim($this->input->post('reminder'));
		
		$arr['nama_file'] = trim($this->input->post('nama_file'));
		$arr['filesize'] = trim($this->input->post('filesize')); 
		$arr['filetype'] = trim($this->input->post('filetype'));  
		
		$arr['type'] = trim($this->input->post('type'));
		$arr['satuan'] = trim($this->input->post('satuan'));
		$arr['qty_awal'] = trim($this->input->post('qty_awal'));
		$arr['qty_akhir'] = trim($this->input->post('qty_akhir'));
		$arr['currency'] = trim($this->input->post('currency'));
		$arr['price'] = trim($this->input->post('price'));
		$arr['penagihan'] = trim($this->input->post('penagihan'));
		
        $this->setup_model->insert_data_contract($arr);		
		// $this->session->set_flashdata('Success', 'Contract successfully inserted!');
	}
	
	function update_data_contract() {
		$arr['doc_induk'] = trim($this->input->post('doc_induk'));
		$arr['doc_id'] = trim($this->input->post('doc_id'));
		$arr['status_id'] = trim($this->input->post('status_id'));
		
		$arr['vendor_id'] = trim($this->input->post('vendor_id'));
		$arr['doc_no'] = trim($this->input->post('doc_no'));
		$arr['doc_title'] = trim($this->input->post('doc_title'));
		$arr['date1'] = trim($this->input->post('date1'));
		$arr['date2'] = trim($this->input->post('date2'));
		$arr['description'] = trim($this->input->post('description'));
		$arr['reminder'] = trim($this->input->post('reminder'));
		$arr['nama_file'] = trim($this->input->post('nama_file'));
		
		$arr['filesize'] = trim($this->input->post('filesize')); 
		$arr['filetype'] = trim($this->input->post('filetype'));  
		
		$arr['type'] = trim($this->input->post('type'));
		$arr['satuan'] = trim($this->input->post('satuan'));
		$arr['qty_awal'] = trim($this->input->post('qty_awal'));
		$arr['qty_akhir'] = trim($this->input->post('qty_akhir'));
		$arr['currency'] = trim($this->input->post('currency'));
		$arr['price'] = trim($this->input->post('price'));
		$arr['penagihan'] = trim($this->input->post('penagihan'));
		
        $this->setup_model->update_data_contract($arr);		
		// $this->session->set_flashdata('Success', 'Contract successfully updated!');
	}
	
	function delete_data_contract() {
		$arr['doc_id'] = trim($this->input->post('doc_id'));		
		$this->setup_model->delete_data_contract($arr);
		
		$arr['search_by_id'] = trim($this->input->post('search_by_id'));
        $arr['search_by_no'] = trim($this->input->post('search_by_no'));
		$arr['search_by_title'] = trim($this->input->post('search_by_title'));
		$arr['search_by_vendor'] = trim($this->input->post('search_by_vendor'));
		
		$this->mypaging->items_total = $this->setup_model->count_contract($arr);
        $this->mypaging->function_load = "load_page_contract";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 9;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
		
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();
		
		$data['list_data'] = $this->setup_model->list_contract($arr, $limit);
        $this->load->view('setup_contract/contract_list_view', $data);
	}
	
	function insert_data_table() {
		$arr['doc_id'] = trim($this->input->post('doc_id')); 
		$arr['type'] = trim($this->input->post('type'));
		$arr['satuan'] = trim($this->input->post('satuan'));
		$arr['qty_awal'] = trim($this->input->post('qty_awal'));
		$arr['qty_akhir'] = trim($this->input->post('qty_akhir'));
		$arr['currency'] = trim($this->input->post('currency'));
		$arr['price'] = trim($this->input->post('price'));
		$arr['penagihan'] = trim($this->input->post('penagihan'));
		
        $this->setup_model->insert_data_table($arr);		
		// $this->session->set_flashdata('Success', 'Table Price successfully inserted!');
		
		$data['dt1'] = date("d/m/Y",now());	
		$data['dt2'] = date("d/m/Y",now());
		
		$data['type_select'] = $this->setup_model->getTypePriceList();
		$data['vendor_select'] = $this->setup_model->getVendorList();
		$data['satuan_select'] = $this->setup_model->getTypeSatuanList();
		
        $arr['doc_id'] = trim($this->input->post('doc_id'));
		$arr['doc_induk'] = trim($this->input->post('doc_induk'));
		
        $data['detail_data'] = $this->setup_model->contract_list_updated($arr);
		$data['table_data'] = $this->setup_model->contract_table_updated($arr);
        
		$data['status_id'] = trim($this->input->post('status_id'));
		$this->load->view('setup_contract/contract_edit_view', $data);
	}
	
	function edit_data_table() {
		$data['type_select'] = $this->setup_model->getTypePriceList();
		$data['satuan_select'] = $this->setup_model->getTypeSatuanList();
	
		$arr['det_id'] = trim($this->input->post('det_id')); 
		$data['det_id'] = trim($this->input->post('det_id')); 
		
		$data['doc_id'] = trim($this->input->post('doc_id'));
		$data['doc_induk'] = trim($this->input->post('doc_induk'));
		$data['status_id'] = trim($this->input->post('status_id')); 
		
		$data['detail_data_table'] = $this->setup_model->edit_data_table_list($arr);
        $this->load->view('setup_contract/edit_data_table_view', $data);
	}
	
	function update_data_table() {
		$arr['det_id'] = trim($this->input->post('det_id')); 
		$arr['det_type_price'] = trim($this->input->post('det_type_price')); 		
		
		$data['doc_id'] = trim($this->input->post('doc_id'));
		$data['doc_induk'] = trim($this->input->post('doc_induk'));
		$data['status_id'] = trim($this->input->post('status_id')); 
		
		$arr['type'] = trim($this->input->post('type'));
		$arr['satuan'] = trim($this->input->post('satuan'));
		$arr['qty_awal'] = trim($this->input->post('qty_awal'));
		$arr['qty_akhir'] = trim($this->input->post('qty_akhir'));
		$arr['currency'] = trim($this->input->post('currency'));
		$arr['price'] = trim($this->input->post('price'));
		$arr['penagihan'] = trim($this->input->post('penagihan'));
		
        $this->setup_model->update_data_table($arr);		
		// $this->session->set_flashdata('Success', 'Table Price successfully updated!');
		
		$data['dt1'] = date("d/m/Y",now());	
		$data['dt2'] = date("d/m/Y",now());
		
		$data['type_select'] = $this->setup_model->getTypePriceList();
		$data['vendor_select'] = $this->setup_model->getVendorList();
		$data['satuan_select'] = $this->setup_model->getTypeSatuanList();
		
		$arr['doc_id'] = trim($this->input->post('doc_id'));
		$arr['doc_induk'] = trim($this->input->post('doc_induk'));
		
      	$data['detail_data'] = $this->setup_model->contract_list_updated($arr);
		$data['table_data'] = $this->setup_model->contract_table_updated($arr);
        
		$this->load->view('setup_contract/contract_edit_view', $data);
	}
	
	function globals_ven_Search()
	{
	   $Ven_Name[] = SearchDetailVen($this->security->xss_clean($this->input->post('SearchName'),$this->input->post('nilai')));
        //$Ven_Name[] = SearchDetailVen($this->security->xss_clean($this->input->post('SearchName')));
		foreach($Ven_Name AS $Ven_Name =>$keyVal)
		{
			$data['Show_Name'] = $keyVal['arr_Name'];
		}
        //echo $this->input->post('SearchName'); exit();
		echo json_encode($data);
	}
	
	//===============================================================================================================
    // ROOM CONTROLLER ~ SURYA ALAM GULTOM 
    //===============================================================================================================
    
    function room() {
        $arr['search_by_room'] = trim($this->input->post('search_by_room'));
        $arr['search_by_floor'] = trim($this->input->post('search_by_floor'));
        $arr['search_by_type'] = trim($this->input->post('search_by_type'));

        $this->mypaging->items_total = $this->setup_model->count_room($arr);
        $this->mypaging->function_load = "load_page_room";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 9;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
		
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();
		
		$data['floor_select'] = $this->setup_model->getFloorList();
		$data['type_select'] = $this->setup_model->getTypeList();

        $data['list_data'] = $this->setup_model->list_room($arr, $limit);
        $this->load->view('setup_room/room_list_view', $data);
    }
	
	function result_room() {
        $cek1 = $this->session->flashdata('search_by_room');
        $cek2 = $this->session->flashdata('search_by_floor');
        $cek3 = $this->session->flashdata('search_by_type');
        
        if ($cek1 != '' || $cek2 != ''|| $cek3 != '') {
            $arr['search_by_room'] = trim($this->session->flashdata('search_by_room'));
            $arr['search_by_floor'] = trim($this->session->flashdata('search_by_floor'));
            $arr['search_by_type'] = trim($this->session->flashdata('search_by_type'));
        } else {
            $arr['search_by_room'] = trim($this->input->post('search_by_room'));
            $arr['search_by_floor'] = trim($this->input->post('search_by_floor'));
            $arr['search_by_type'] = trim($this->input->post('search_by_type'));
        }

        $this->mypaging->items_total = $this->setup_model->count_room($arr);
        $this->mypaging->function_load = "load_page_room";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 9;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
		
        $data['page'] = 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();
        $data['parameter'] = $arr;

        $data['list_data'] = $this->setup_model->search_room($arr, $limit);
        $this->load->view("setup_room/room_result_view", $data);
    }
	
	function search_room() {
        $arr['search_by_room'] = trim($this->input->post('search_by_room'));
        $arr['search_by_floor'] = trim($this->input->post('search_by_floor'));
        $arr['search_by_type'] = trim($this->input->post('search_by_type'));

        $this->mypaging->items_total = $this->setup_model->count_room($arr);
        $this->mypaging->function_load = "load_page_room";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 9;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
		
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->search_room($arr, $limit);
        $this->load->view('setup_room/room_search_view', $data);
    }
	
	function edit_room() {
		$data['floor_select'] = $this->setup_model->getFloorList();
		$data['type_select'] = $this->setup_model->getTypeList();
		
        $arr['room_id'] = trim($this->input->post('room_id'));
        $data['detail_data'] = $this->setup_model->room_list($arr);
        $this->load->view('setup_room/room_edit_view', $data);
    }
	
	function delete_room() {
		$arr['room_id'] = trim($this->input->post('room_id'));
        $this->setup_model->delete_master_room($arr);
		
		$arr['search_by_room'] = trim($this->input->post('search_by_room'));
        $arr['search_by_floor'] = trim($this->input->post('search_by_floor'));
        $arr['search_by_type'] = trim($this->input->post('search_by_type'));

        $this->mypaging->items_total = $this->setup_model->count_room($arr);
        $this->mypaging->function_load = "load_page_room";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 9;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
		
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();
		
		$data['floor_select'] = $this->setup_model->getFloorList();
		$data['type_select'] = $this->setup_model->getTypeList();

        $data['list_data'] = $this->setup_model->list_room($arr, $limit);
        $this->load->view('setup_room/room_list_view', $data);
	}
	
	function view_detail() {
		$arr['room_id'] = trim($this->input->post('room_id'));
		$arr['type'] = trim($this->input->post('type'));
		
		$data['header_data'] = $this->setup_model->header_data($arr);
		$data['list_data'] = $this->setup_model->view_detail_room($arr);
		
		$data['room_id'] = $arr['room_id'];
		$data['type'] = $arr['type'];		
		$this->load->view('setup_room/detail_room_view', $data);
	}
	
	function view_master_item() {
		$data['list_data'] = $this->setup_model->view_master_item();
		$this->load->view('setup_room/master_item_view', $data);
	}
	
	function delete_master_item() {
		$arr['public_room_id'] = trim($this->input->post('public_room_id'));
        $this->setup_model->delete_master_item($arr);
		
		$data['list_data'] = $this->setup_model->view_master_item();
		$this->load->view('setup_room/master_item_view', $data);
	}
	
	function edit_master_item() {
		$arr['item'] = trim($this->input->post('item'));
		$arr['quantity'] = trim($this->input->post('quantity'));
		$arr['uom'] = trim($this->input->post('uom'));
		$arr['status'] = trim($this->input->post('status'));
		$arr['public_room_id'] = trim($this->input->post('public_room_id'));
        $this->setup_model->edit_master_item($arr);
		
		$data['list_data'] = $this->setup_model->view_master_item();
		$this->load->view('setup_room/master_item_view', $data);
	}
	
	function edit_master_view() {
		$arr['public_room_id'] = trim($this->input->post('public_room_id'));
        $data['list_data'] = $this->setup_model->edit_master_view($arr);
        $this->load->view('setup_room/room_item_edit_view', $data);
	}
	
	function add_detail() {
		$arr['room_id'] = trim($this->input->post('room_id'));
		$arr['type'] = trim($this->input->post('type'));
        $data['list_data'] = $this->setup_model->add_detail_room($arr);
		
		$data['room_id'] = $arr['room_id'];
		$data['type'] = $arr['type'];		
        $this->load->view('setup_room/add_detail_view', $data);
	}
	
	function delete_detail() {
		$arr['room_id'] = trim($this->input->post('room_id'));
		$arr['type'] = trim($this->input->post('type'));
		$arr['public_room_id'] = trim($this->input->post('public_room_id'));
        $this->setup_model->delete_detail_room($arr);
		
		$arr2['room_id'] = trim($this->input->post('room_id'));
		$arr2['type'] = trim($this->input->post('type'));
		
		$data['header_data'] = $this->setup_model->header_data($arr2);
		$data['list_data'] = $this->setup_model->view_detail_room($arr2);
		
		$data['room_id'] = $arr2['room_id'];
		$data['type'] = $arr2['type'];		
		$this->load->view('setup_room/detail_room_view', $data);
	}
	
	function edit_detail() {
		$arr['room_id'] = trim($this->input->post('room_id'));
		$arr['type'] = trim($this->input->post('type'));
		$arr['public_room_id'] = trim($this->input->post('public_room_id'));
        
		$data['list_data'] = $this->setup_model->list_data_detail($arr);
		
		$arr2['room_id'] = trim($this->input->post('room_id'));
		$arr2['type'] = trim($this->input->post('type'));		
		$data['header_data'] = $this->setup_model->header_data($arr2);				
		
		$data['room_id'] = $arr2['room_id'];
		$data['type'] = $arr2['type'];				
		$data['public_room_id'] = $arr['public_room_id'];
		$this->load->view('setup_room/edit_detail_view', $data);				
	}		
	
	function save_detail() {
		$arr['room_id'] = trim($this->input->post('room_id'));
		$arr['type'] = trim($this->input->post('type'));
		$arr['public_room_id'] = trim($this->input->post('public_room_id'));
        $this->setup_model->save_detail_room($arr);
		
		$arr2['room_id'] = trim($this->input->post('room_id'));
		$arr2['type'] = trim($this->input->post('type'));
		
		$data['header_data'] = $this->setup_model->header_data($arr2);
		$data['list_data'] = $this->setup_model->view_detail_room($arr2);
		
		$data['room_id'] = $arr2['room_id'];
		$data['type'] = $arr2['type'];		
		$this->load->view('setup_room/detail_room_view', $data);
	}
	
	function save_detail2() {
		$arr['room_id'] = trim($this->input->post('room_id'));
		$arr['type'] = trim($this->input->post('type'));
		$arr['qty'] = trim($this->input->post('qty'));
		$arr['uom'] = trim($this->input->post('uom'));
		$arr['public_room_id'] = trim($this->input->post('public_room_id'));
        $this->setup_model->save_detail_room2($arr);
		
		$arr2['room_id'] = trim($this->input->post('room_id'));
		$arr2['type'] = trim($this->input->post('type'));
		
		$data['header_data'] = $this->setup_model->header_data($arr2);
		$data['list_data'] = $this->setup_model->view_detail_room($arr2);
		
		$data['room_id'] = $arr2['room_id'];
		$data['type'] = $arr2['type'];		
		$this->load->view('setup_room/detail_room_view', $data);
	}
	
	function add_room() {
		$data['floor_select'] = $this->setup_model->getFloorList();
		$data['type_select'] = $this->setup_model->getTypeList();
        $this->load->view('setup_room/room_add_view', $data);
    }
	
	function add_room_item() {
        $this->load->view('setup_room/room_item_add_view');
    }
	
	function activation_room() {
        $arr['room_id'] = trim($this->input->post('room_id'));
        $arr['cond'] = ($this->input->post('cond')=='Y') ? 'N' : 'Y';        
        $this->setup_model->update_status_room($arr);
    }
	
	function load_page_room() {
        $cek1 = $this->session->flashdata('search_by_room');
        $cek2 = $this->session->flashdata('search_by_floor');
        $cek3 = $this->session->flashdata('search_by_type');
        
        if ($cek1 != '' || $cek2 != ''|| $cek3 != '') {
            $arr['search_by_room'] = trim($this->session->flashdata('search_by_room'));
            $arr['search_by_floor'] = trim($this->session->flashdata('search_by_floor'));
            $arr['search_by_type'] = trim($this->session->flashdata('search_by_type'));
        } else {
            $arr['search_by_room'] = trim($this->input->post('search_by_room'));
            $arr['search_by_floor'] = trim($this->input->post('search_by_floor'));
            $arr['search_by_type'] = trim($this->input->post('search_by_type'));
        }

        $this->mypaging->items_total = $this->setup_model->count_room($arr);
        $this->mypaging->function_load = "load_page_room";
        $this->mypaging->post_page = trim($this->input->post("page"));
        $this->mypaging->post_ipp = trim($this->input->post("ipp"));
        $this->mypaging->mid_range = 9;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
		
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->search_room($arr, $limit);
        $this->load->view('setup_room/room_search_view', $data);
    }
	
	function update_room() {
        $arr['room_id'] = trim($this->input->post('room_id'));        
		$arr['room'] = trim($this->input->post('room'));
		$arr['type'] = trim($this->input->post('type'));
		$arr['floor'] = trim($this->input->post('floor'));
		$arr['status'] = trim($this->input->post('status'));
		$arr['capacity'] = trim($this->input->post('capacity'));        
        $this->setup_model->update_room($arr);        
        // $this->session->set_flashdata('Success', 'Room successfully updated!');
    }	
	
	function insert_room() {
		$arr['room'] = trim($this->input->post('room'));
		$arr['type'] = trim($this->input->post('type'));
		$arr['floor'] = trim($this->input->post('floor'));
		$arr['status'] = trim($this->input->post('status'));
		$arr['capacity'] = trim($this->input->post('capacity'));		        
        $this->setup_model->insert_room($arr);        
        // $this->session->set_flashdata('Success', 'Room successfully inserted!');
    }
	
	function insert_room_item() {
		$arr['item'] = trim($this->input->post('item'));
		$arr['quantity'] = trim($this->input->post('quantity'));
		$arr['uom'] = trim($this->input->post('uom'));
		$arr['status'] = trim($this->input->post('status'));				        
        $this->setup_model->insert_room_item($arr);        
        // $this->session->set_flashdata('Success', 'Master Item successfully inserted!');
    }
	
	//===============================================================================================================
    // AREA CONTROLLER, By : Hasyim A
    //===============================================================================================================

    function area() {
        $arr['search_by_regional'] = trim($this->input->post('search_by_regional'));
        $arr['search_by_status'] = trim($this->input->post('search_by_status'));
        $arr['search_by_type'] = trim($this->input->post('search_by_type'));

        $this->mypaging->items_total = $this->setup_model->count_area($arr);
        $this->mypaging->function_load = "load_page_area";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 5;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->list_area($arr, $limit);
        $this->load->view('setup_area/area_list_view', $data);
    }

    function search_area() {
        $arr['search_by_regional'] = trim($this->input->post('search_by_regional'));
        $arr['search_by_status'] = trim($this->input->post('search_by_status'));
        $arr['search_by_type'] = trim($this->input->post('search_by_type'));

        $this->mypaging->items_total = $this->setup_model->count_area($arr);
        $this->mypaging->function_load = "load_page_area";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 5;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->search_area($arr, $limit);
        $this->load->view('setup_area/area_search_view', $data);
    }

    function load_page_area() {
        $cek1 = $this->session->flashdata('search_by_regional');
        $cek2 = $this->session->flashdata('search_by_status');
        $cek3 = $this->session->flashdata('search_by_type');

        if ($cek1 != '' || $cek2 != '' || $cek3 != '') {
            $arr['search_by_regional'] = trim($this->session->flashdata('search_by_regional'));
            $arr['search_by_status'] = trim($this->session->flashdata('search_by_status'));
            $arr['search_by_type'] = trim($this->session->flashdata('search_by_type'));
        } else {
            $arr['search_by_regional'] = trim($this->input->post('search_by_regional'));
            $arr['search_by_status'] = trim($this->input->post('search_by_status'));
            $arr['search_by_type'] = trim($this->input->post('search_by_type'));
        }

        $this->mypaging->items_total = $this->setup_model->count_area($arr);
        $this->mypaging->function_load = "load_page_area";
        $this->mypaging->post_page = trim($this->input->post("page"));
        $this->mypaging->post_ipp = trim($this->input->post("ipp"));
        $this->mypaging->mid_range = 5;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->search_area($arr, $limit);
        $this->load->view('setup_area/area_search_view', $data);
    }

    function add_area() {
        $this->load->view('setup_area/area_add_view');
    }

    function insert_area() {
        $arr['area'] = trim($this->input->post('area'));
        $arr['regional'] = strtoupper(trim($this->input->post('regional')));
        $arr['officename'] = strtoupper(trim($this->input->post('officename')));
        $arr['address'] = trim($this->input->post('address'));
        $arr['status'] = trim($this->input->post('status'));
        $arr['type'] = trim($this->input->post('type'));

        $this->setup_model->insert_area($arr);
        // $this->session->set_flashdata('Success', 'Data successfully inserted!');
    }

    function edit_area() {
        $arr['id'] = trim($this->input->post('id'));
        $data['detil_data'] = $this->setup_model->detil_area($arr);
        $this->load->view('setup_area/area_edit_view', $data);
    }

    function update_area() {
        $arr['idarea'] = trim($this->input->post('idarea'));
        $arr['area'] = trim($this->input->post('area'));
        $arr['regional'] = strtoupper(trim($this->input->post('regional')));
        $arr['officename'] = strtoupper(trim($this->input->post('officename')));
        $arr['address'] = trim($this->input->post('address'));
        $arr['status'] = trim($this->input->post('status'));
        $arr['type'] = trim($this->input->post('type'));

        $this->setup_model->update_area($arr);
        //$this->session->set_flashdata('Success', 'Data successfully updated!');
    }

    function activation_area() {
        $arr['id'] = trim($this->input->post('id'));
        $arr['cond'] = ($this->input->post('cond') == 'Y') ? 'N' : 'Y';

        $this->setup_model->update_status_area($arr);
    }

    //===============================================================================================================
    // END OF AREA CONTROLLER
    //===============================================================================================================
    //===============================================================================================================
    // COURIER CONTROLLER, By : Hasyim A
    //===============================================================================================================

    function courier() {
        $arr['search_by_courier'] = trim($this->input->post('search_by_courier'));
        $arr['search_by_area'] = trim($this->input->post('search_by_area'));
        $arr['search_by_regional'] = trim($this->input->post('search_by_regional'));
        $arr['search_by_status'] = trim($this->input->post('search_by_status'));

        $this->mypaging->items_total = $this->setup_model->count_courier($arr);
        $this->mypaging->function_load = "load_page_courier";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 5;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->list_courier($arr, $limit);
        $data['list_area'] = $this->setup_model->courier_area_list();
        $this->load->view('setup_courier/courier_list_view', $data);
    }

    function search_courier() {
        $arr['search_by_courier'] = trim($this->input->post('search_by_courier'));
        $arr['search_by_area'] = trim($this->input->post('search_by_area'));
        $arr['search_by_regional'] = trim($this->input->post('search_by_regional'));
        $arr['search_by_status'] = trim($this->input->post('search_by_status'));

        $this->mypaging->items_total = $this->setup_model->count_courier($arr);
        $this->mypaging->function_load = "load_page_courier";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 5;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->search_courier($arr, $limit);
        $this->load->view('setup_courier/courier_search_view', $data);
    }

    function load_page_courier() {
        $cek1 = $this->session->flashdata('search_by_courier');
        $cek2 = $this->session->flashdata('search_by_area');
        $cek3 = $this->session->flashdata('search_by_regional');
        $cek4 = $this->session->flashdata('search_by_status');

        if ($cek1 != '' || $cek2 != '' || $cek3 != '' || $cek4 != '') {
            $arr['search_by_courier'] = trim($this->session->flashdata('search_by_courier'));
            $arr['search_by_area'] = trim($this->session->flashdata('search_by_area'));
            $arr['search_by_regional'] = trim($this->session->flashdata('search_by_regional'));
            $arr['search_by_status'] = trim($this->session->flashdata('search_by_status'));
        } else {
            $arr['search_by_courier'] = trim($this->input->post('search_by_courier'));
            $arr['search_by_area'] = trim($this->input->post('search_by_area'));
            $arr['search_by_regional'] = trim($this->input->post('search_by_regional'));
            $arr['search_by_status'] = trim($this->input->post('search_by_status'));
        }

        $this->mypaging->items_total = $this->setup_model->count_courier($arr);
        $this->mypaging->function_load = "load_page_courier";
        $this->mypaging->post_page = trim($this->input->post("page"));
        $this->mypaging->post_ipp = trim($this->input->post("ipp"));
        $this->mypaging->mid_range = 5;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->search_courier($arr, $limit);
        $this->load->view('setup_courier/courier_search_view', $data);
    }

//    function delete_courier() {
//        $arr['nama'] = validate_special(trim($this->input->post('id')));
//
//        $this->session->set_flashdata('search_by_jenis', validate_special(trim($this->input->post('search_by_jenis'))));
//        $this->session->set_flashdata('search_by_harga', validate_special(trim($this->input->post('search_by_harga'))));
//
//        $this->setup_model->delete_data($arr);
//        redirect('setting_bahan_bakar/result_data');
//    }

    function check_area() {
        $arr['area'] = trim($this->input->post('area'));
        $result = $this->setup_model->check_area($arr);

        if ($result['ISDOMESTIC'] == 'Y') {
            echo 'DOMESTIC';
        } else {
            echo 'INTERNATIONAL';
        }
    }

    function add_courier() {
        $data['courier_list'] = $this->setup_model->courier_list_add();
        $data['area_list'] = $this->setup_model->courier_area_list_add();
        $this->load->view('setup_courier/courier_add_view', $data);
    }

    function insert_courier() {
        $arr['couriername'] = trim($this->input->post('couriername'));
        $arr['couriernew'] = trim($this->input->post('other_courier'));
        $arr['areaname'] = strtoupper(trim($this->input->post('areaname')));
        //$arr['services'] = strtoupper(trim($this->input->post('services')));
        $arr['status'] = trim($this->input->post('status'));
        $arr['price1kg'] = trim($this->input->post('price1kg'));
        $arr['price15kg'] = trim($this->input->post('price15kg'));
        $arr['price5kg'] = trim($this->input->post('price5kg'));

        $this->setup_model->insert_courier($arr);
    }

    function edit_courier() {
        $arr['price_id'] = trim($this->input->post('price_id'));
        $data['detil_data'] = $this->setup_model->detil_courier($arr);
        $data['courier_list'] = $this->setup_model->courier_list_add();
        $data['area_list'] = $this->setup_model->courier_area_list_add();
        $this->load->view('setup_courier/courier_edit_view', $data);
    }

    function update_courier() {
        $arr['status'] = trim($this->input->post('status'));
        $arr['price1kg'] = trim($this->input->post('price1kg'));
        $arr['price15kg'] = trim($this->input->post('price15kg'));
        $arr['price5kg'] = trim($this->input->post('price5kg'));
        $arr['price_id'] = trim($this->input->post('price_id'));

        $this->setup_model->update_courier($arr);
    }

    function activation_courier() {
        $arr['id'] = trim($this->input->post('id'));
        $arr['cond'] = ($this->input->post('cond') == 'Y') ? 'N' : 'Y';

        $this->setup_model->update_status_courier($arr);
    }

    function get_regional() {
        $area = trim($this->input->post('area'));
        if (!empty($area)) {
            $regional_list = $this->setup_model->courier_regional_list($area);
            echo '<option value="">-- select --</option>';
            if (!empty($regional_list)) {
                foreach ($regional_list as $row) {
                    echo '<option value="' . strtoupper($row['REGIONAL_NAME']) . '">' . strtoupper($row['REGIONAL_NAME']) . '</option>';
                }
            }
        } else {
            echo '<option value="">-- select --</option>';
        }
    }

    //===============================================================================================================
    // END OF COURIER CONTROLLER
    //===============================================================================================================
    //===============================================================================================================
    // MESSENGER CONTROLLER, By : Hasyim A
    //===============================================================================================================

    function messenger() {
        $arr['search_by_messenger'] = trim($this->input->post('search_by_messenger'));
        $arr['search_by_date'] = trim($this->input->post('search_by_date'));
        $arr['search_by_approval'] = trim($this->input->post('search_by_approval'));
        $arr['search_by_status'] = trim($this->input->post('search_by_status'));

        $this->mypaging->items_total = $this->setup_model->count_messenger($arr);
        $this->mypaging->function_load = "load_page_messenger";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 5;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();
		
		$data['list_data'] = $this->setup_model->list_messenger($arr, $limit);
        $data['messenger'] = $this->setup_model->messenger_list();
        $this->load->view('setup_messenger/messenger_list_view', $data);
    }

    function search_messenger() {
        $arr['search_by_messenger'] = trim($this->input->post('search_by_messenger'));
        $arr['search_by_date'] = trim($this->input->post('search_by_date'));
        $arr['search_by_approval'] = trim($this->input->post('search_by_approval'));
        $arr['search_by_status'] = trim($this->input->post('search_by_status'));

        $this->mypaging->items_total = $this->setup_model->count_messenger($arr);
        $this->mypaging->function_load = "load_page_messenger";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 5;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->search_messenger($arr, $limit);
        $data['messenger'] = $this->setup_model->messenger_list();
        $this->load->view('setup_messenger/messenger_search_view', $data);
    }

    function load_page_messenger() {
        $cek1 = $this->session->flashdata('search_by_messenger');
        $cek2 = $this->session->flashdata('search_by_date');
        $cek3 = $this->session->flashdata('search_by_approval');
        $cek4 = $this->session->flashdata('search_by_status');

        if ($cek1 != '' || $cek2 != '' || $cek3 != '' || $cek4 != '') {
            $arr['search_by_messenger'] = trim($this->session->flashdata('search_by_messenger'));
            $arr['search_by_date'] = trim($this->session->flashdata('search_by_date'));
            $arr['search_by_approval'] = trim($this->session->flashdata('search_by_approval'));
            $arr['search_by_status'] = trim($this->session->flashdata('search_by_status'));
        } else {
            $arr['search_by_messenger'] = trim($this->input->post('search_by_messenger'));
            $arr['search_by_date'] = trim($this->input->post('search_by_date'));
            $arr['search_by_approval'] = trim($this->input->post('search_by_approval'));
            $arr['search_by_status'] = trim($this->input->post('search_by_status'));
        }

        $this->mypaging->items_total = $this->setup_model->count_messenger($arr);
        $this->mypaging->function_load = "load_page_messenger";
        $this->mypaging->post_page = trim($this->input->post("page"));
        $this->mypaging->post_ipp = trim($this->input->post("ipp"));
        $this->mypaging->mid_range = 5;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->search_messenger($arr, $limit);
        $data['messenger'] = $this->setup_model->messenger_list();
        $this->load->view('setup_messenger/messenger_search_view', $data);
    }

    function add_messenger() {
        $data['courier_list'] = $this->setup_model->courier_list_add();
        $data['area_list'] = $this->setup_model->courier_area_list_add();
        $data['messenger'] = $this->setup_model->messenger_list();
        $this->load->view('setup_messenger/messenger_add_view', $data);
    }

    function insert_messenger() {
        $arr['date1'] = trim($this->input->post('date1'));
        $arr['date2'] = trim($this->input->post('date2'));
        $arr['messengername'] = strtoupper(trim($this->input->post('messengername')));
        $arr['assignto'] = strtoupper(trim($this->input->post('assignto')));
        $arr['description'] = trim($this->input->post('description'));

        $this->setup_model->insert_messenger($arr);
    }

    function add_messenger_list() {
        $this->load->view('setup_messenger/messenger_add_messenger_view');
    }

    function insert_messenger_list() {
        $arr['messengername'] = trim($this->input->post('messengername'));
        $arr['messengerphone'] = trim($this->input->post('messengerphone'));
        $arr['messengerstatus'] = strtoupper(trim($this->input->post('messengerstatus')));

        $this->setup_model->insert_messenger_list($arr);
    }

    //===============================================================================================================
    // END OF MESSENGER CONTROLLER
    //===============================================================================================================
    //===============================================================================================================
    // APPROVAL MESSENGER CONTROLLER, By : Hasyim A
    //===============================================================================================================

    function approval_messenger() {
        $arr['search_by_messenger'] = trim($this->input->post('search_by_messenger'));
        $arr['search_by_date'] = trim($this->input->post('search_by_date'));
        $arr['search_by_approval'] = trim($this->input->post('search_by_approval'));
        $arr['search_by_status'] = trim($this->input->post('search_by_status'));

        $this->mypaging->items_total = $this->setup_model->count_approval_messenger($arr);
        $this->mypaging->function_load = "load_page_messenger";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 5;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();
	
		$data['list_data'] = $this->setup_model->list_approval_messenger($arr, $limit);
        $data['messenger'] = $this->setup_model->messenger_list();
        $this->load->view('setup_approval_messenger/approval_messenger_list_view', $data);
    }

    function search_approval_messenger() {
        $arr['search_by_messenger'] = trim($this->input->post('search_by_messenger'));
        $arr['search_by_date'] = trim($this->input->post('search_by_date'));
        $arr['search_by_approval'] = trim($this->input->post('search_by_approval'));
        $arr['search_by_status'] = trim($this->input->post('search_by_status'));

        $this->mypaging->items_total = $this->setup_model->count_approval_messenger($arr);
        $this->mypaging->function_load = "load_page_messenger";
        $this->mypaging->post_page = 1;
        $this->mypaging->post_ipp = 10;
        $this->mypaging->mid_range = 5;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->search_approval_messenger($arr, $limit);
        $data['messenger'] = $this->setup_model->messenger_list();
        $this->load->view('setup_approval_messenger/approval_messenger_search_view', $data);
    }

    function load_page_approval_messenger() {
        $cek1 = $this->session->flashdata('search_by_messenger');
        $cek2 = $this->session->flashdata('search_by_date');
        $cek3 = $this->session->flashdata('search_by_approval');
        $cek4 = $this->session->flashdata('search_by_status');

        if ($cek1 != '' || $cek2 != '' || $cek3 != '' || $cek4 != '') {
            $arr['search_by_messenger'] = trim($this->session->flashdata('search_by_messenger'));
            $arr['search_by_date'] = trim($this->session->flashdata('search_by_date'));
            $arr['search_by_approval'] = trim($this->session->flashdata('search_by_approval'));
            $arr['search_by_status'] = trim($this->session->flashdata('search_by_status'));
        } else {
            $arr['search_by_messenger'] = trim($this->input->post('search_by_messenger'));
            $arr['search_by_date'] = trim($this->input->post('search_by_date'));
            $arr['search_by_approval'] = trim($this->input->post('search_by_approval'));
            $arr['search_by_status'] = trim($this->input->post('search_by_status'));
        }

        $this->mypaging->items_total = $this->setup_model->count_approval_messenger($arr);
        $this->mypaging->function_load = "load_page_messenger";
        $this->mypaging->post_page = trim($this->input->post("page"));
        $this->mypaging->post_ipp = trim($this->input->post("ipp"));
        $this->mypaging->mid_range = 5;
        $this->mypaging->paginate();
        $limit = $this->mypaging->limit;
        $data['page'] = (($this->input->post("page") - 1) * $this->input->post("ipp")) + 1;
        $data['paging'] = $this->mypaging->display_pages();
        $data['jump_page'] = $this->mypaging->display_jump_menu();
        $data['ipp'] = $this->mypaging->display_items_per_page();

        $data['list_data'] = $this->setup_model->search_approval_messenger($arr, $limit);
        $data['messenger'] = $this->setup_model->messenger_list();
        $this->load->view('setup_approval_messenger/approval_messenger_search_view', $data);
    }

	function approve_now() {
        $arr['messenger_trans_id'] = trim($this->input->post('messenger_trans_id'));
        $arr['cond'] = ($this->input->post('cond')=='Y') ? 'N' : 'Y';        
        $this->setup_model->update_status_messanger($arr);
    }
	
    function update_approval() {
        /*
		$loop = intval($_POST['jumlah_row']);
        
        for($a=0;$a<$loop;$a++){
                $arr['trans_id'] = !empty($_POST['trans_id'][$a]) ? $_POST['trans_id'][$a] : '';
                $arr['trans_app'] = !empty($_POST['trans_app'][$a]) ? $_POST['trans_app'][$a] : '';
                
                $this->setup_model->update_approval_messenger($arr);
        }
        redirect(base_url().'setup/approval_messenger');
		*/
    }

    //===============================================================================================================
    // END OF APPROVAL MESSENGER CONTROLLER
    //===============================================================================================================
    
}